package com.fqgj.xjd.user.dao.impl;
import com.fqgj.common.api.Page;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.xjd.user.dao.UserBehaviorRegisterDao;
import com.fqgj.xjd.user.entity.UserBehaviorRegisterEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* User: zhangxingyun
* Date: 2017-07-20
* Time: 18:38:53.062
*/

@Repository
public class UserBehaviorRegisterDaoImpl extends AbstractBaseMapper<UserBehaviorRegisterEntity> implements UserBehaviorRegisterDao {

    @Override
    public UserBehaviorRegisterEntity selectUserBehaviorRegisterByUserCodeAndAppCode(String userCode) {
        Map params = new HashMap();
        params.put("userCode",userCode);
        return getSqlSession().selectOne(getStatement("selectUserBehaviorRegisterByUserCodeAndAppCode"),params);
    }

    @Override
    public List<UserBehaviorRegisterEntity> selectUserRegisterByClientId(String clientId) {
        return getSqlSession().selectList(getStatement("selectUserRegisterByClientId"),clientId);
    }

    @Override
    public List<UserBehaviorRegisterEntity> selectUserRegisterByPage(Page page) {
        Map params = new HashMap();
        params.put("page",page);
        return getSqlSession().selectList(getStatement("selectUserRegisterByPage"),params);
    }

    @Override
    public Integer countTotalByRegisterFrom(String registerFrom, String appCode, Integer biz) {
        Map params = new HashMap();
        params.put("registerFrom",registerFrom);
        params.put("appCode",String.valueOf(appCode));
        params.put("biz",biz);
        return getSqlSession().selectOne(getStatement("countTotalByRegisterFrom"),params);
    }

    @Override
    public List<String> pagedQueryUserByRegisterFrom(String registerFrom, String appCode,
                                                               Integer biz, Integer start,Integer pageSize){
        Map params = new HashMap();
        params.put("registerFrom",registerFrom);
        params.put("appCode",String.valueOf(appCode));
        params.put("biz",biz);
        params.put("start",start);
        params.put("pageSize",pageSize);
        return getSqlSession().selectList(getStatement("pagedQueryUserByRegisterFrom"),params);
    }

    @Override
    public List<String> selectLatestRegisterChannelByHour(int hour) {
        Map params = new HashMap();
        params.put("hour",hour);
        return getSqlSession().selectList(getStatement("selectLatestRegisterChannelByHour"), params);
    }
}